const faker = require('faker');

faker.locale = 'zh_CN';

// 物料
const purchaseList = [];
for (let i = 0; i < 20; i++) {
  purchaseList.push({
    skuId: faker.random.uuid(),
    skuName: `名称${i}`,
    skuBrand: Math.floor(Math.random() * 2),
    skuSpecification: `规格${i}`,
    skuUnit: Math.floor(Math.random() * 3),
    skuCategory: Math.floor(Math.random() * 10),
    skuGrade: Math.floor(Math.random() * 3),
    skuProperty: Math.floor(Math.random() * 4),
    bomVersion: `BOM${i}`,
    skuStatus: Math.round(Math.random()),
    storageSite: Math.floor(Math.random() * 3),
    batchNo: Math.round(Math.random() * 10000),
    quantity: Math.round(Math.random() * 10000),
    prodDate: Date.now()
  });
}

const purchaseDetail = [
  {
    id: 'xxxx1',
    orderNo: '112233',
    paymentAmount: '100000',
    currency: '美元',
    paymentFlag: faker.random.number(1),
    paymentDate: '2019-09-09 18:00:00',
    invoiceDate: '2019-09-09 18:00:00',
    invoiceType: faker.random.number(2),
    invoiceAmount: '999999',
    attachList: { id: 'attchx1', name: 'xxxx1', url: 'url1' }
  }, {
    id: 'xxxx2',
    orderNo: '112234',
    paymentAmount: '100000',
    currency: '美元',
    paymentFlag: faker.random.number(1),
    paymentDate: '2019-09-09 18:00:00',
    invoiceDate: '2019-09-09 18:00:00',
    invoiceType: faker.random.number(2),
    invoiceAmount: '999999',
    attachList: { id: 'attchx1', name: 'xxxx2', url: 'url1' }
  }
];

export default {
  // 物料
  getPurchaseList: () => ({
    totalNum: 23,
    records: purchaseList
  }),
  getPurchaseDetail: () => ({
    status: 0,
    obj: purchaseDetail,
    comment: '成功'
  }),
  deletePurchase: () => ({ status: 0 }),
  savePurchase: () => ({
    status: 0,
    comment: '成功',
    obj: purchaseList[Math.floor(Math.random() * 20)]
  })
};
